import { NDataTable, dataTableProps } from 'naive-ui'
import Toolbar from './components/toolbar/index'
import { useProTableState } from '@/components/tables/pro-table/context'

/**
 * @FILENAME:  index.tsx
 *  @Description:  // 通用基础数据表
 * @Author: ellwood
 * @CreateDate: 2024/11/6 - 10:40
 * @Version: V1.0.0
 */
const index = defineComponent({
  name: 'BasicTable',
  props: {
    ...dataTableProps,
  },
  setup(props, { slots }) {
    const prefixCls = 'pro-table-basic-table'
    const state = useProTableState()
    return () => {
      const tableSlots = {
        empty: slots.empty,
        loading: slots.loading,
      }
      return (
        <div class={prefixCls}>
          <Toolbar />
          <NDataTable
            {...props}
            columns={state.settingColumn?.cols.value}
            v-slots={tableSlots}
          >
          </NDataTable>
        </div>
      )
    }
  },
})

export default index
